package com.sanben.common.exception;

import com.sanben.common.enums.ErrorMessage;
import lombok.Getter;


/**
 * @author: cyh
 * @description: 服务异常类
 * @date: 2020/8/03 10:57
 */
@Getter
public class ServiceException extends RuntimeException {

    private int code;
    private String message;
    private Object data;

    public ServiceException(Object data, String message) {
        this.code = 400;
        this.message = message;
        this.data = data;
    }

    public ServiceException(Object data, String message, int code) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ServiceException(String message) {
        this.code = 400;
        this.message = message;
    }

    public ServiceException(ErrorMessage errorMessage) {
        this.code = errorMessage.getCode();
        this.message = errorMessage.getMessage();
    }

    public ServiceException(String message, int code) {
        this.code = code;
        this.message = message;
    }
}